package com.fqr;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class Holiday {

	static DateFormat DF = new SimpleDateFormat("MM/dd/yyyy");

	static Set<Date> holidays = new HashSet<Date>();
	static Set<String> holidayStrings = new HashSet<String>();

	static {
		InputStream is = Holiday.class.getClassLoader().getResourceAsStream(
				"holiday.txt");
		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
		try {
			for (String line = reader.readLine(); line != null; line = reader
					.readLine()) {
				Date d = DateParser.parse(line);
				holidays.add(d);
				holidayStrings.add(DF.format(d));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public static boolean isHoliday(Date d) {
		return holidays.contains(d) || holidayStrings.contains(DF.format(d));
	}
}
